<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>手写bind</title>
</head>
<body>
  
</body>
<script>
  Function.prototype.bind = function() {
    var self = this
    context = [].shift.call(arguments)
    args = [].slice.call(arguments)
    return function() {
      // 把调用bind时的参数，和 后续传递的参数进行拼接
      self.apply(context, [].concat.call(args, [].slice.call(arguments)))
    }
  }
  function test() {
    console.log(Array.prototype.shift.call(arguments))
    console.log(Array.prototype.slice.call(arguments))
  }
  test(1,2,34)
</script>
</html>